package com.yykj.backstage.all.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yykj.backstage.all.dto.AdminMenu;
import com.yykj.backstage.all.form.AdminMenuForm;
import com.yykj.backstage.all.model.entity.AdminOauth;
import com.yykj.backstage.all.service.AdminService;
import com.yykj.base.client.dto.BaseDepartmentDTO;
import com.yykj.base.client.feign.BaseFeignClient;
import com.yykj.common.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/api/backstage/all")
@Api(tags = "总后台相关接口")
@SuppressWarnings(value = "unchecked")
public class BackstageAllController {

    @GetMapping("/base/department")
    @ApiOperation("默认科室--列表")
    public ResultVO<List<BaseDepartmentDTO>> getBaseDepartment(){
        return ResultVO.success(baseFeignClient.getBaseDepartment());
    }

    @ApiOperation("默认科室--修改")
    @PostMapping("/base/department/edit")
    public ResultVO<BaseDepartmentDTO> editBaseDepartment(@RequestBody BaseDepartmentDTO dto) {
        return ResultVO.success(baseFeignClient.editBaseDepartment(dto));
    }

    @ApiOperation("默认科室--添加")
    @ApiOperationSupport(ignoreParameters = { "id" })
    @PostMapping("/base/department/add")
    public ResultVO<BaseDepartmentDTO> addBaseDepartment(@RequestBody BaseDepartmentDTO dto) {
        return ResultVO.success(baseFeignClient.editBaseDepartment(dto));
    }

    @ApiOperation("默认科室--删除")
    @DeleteMapping("/base/department/delete/{id}")
    public ResultVO deleteBaseDepartment(@PathVariable Integer id){
        baseFeignClient.deleteBaseDepartment(id);
        return ResultVO.success();
    }

    private BaseFeignClient baseFeignClient;

    @Autowired
    public void setBaseFeignClient(BaseFeignClient baseFeignClient) {
        this.baseFeignClient = baseFeignClient;
    }

}
